﻿Imports Crystal.CLL
Imports CrystalClientManagement.BLL
Imports Infragistics.Win
Imports System.Text
Imports CrystalClientManagement.BLL.BusinessLayer
Imports Infragistics.Win.UltraWinGrid

Public Class frmAddEditProject
#Region "Declare"
    Public projectID As Integer = 0
    Public Event AddParticularProjectInGrid(ByVal ProjectID As Integer)
    Public IsLoading As Boolean = False
    Public IgnoreEnable As Boolean = False
    Private IsSaved As Boolean = False
    Public ClientID As Integer = 0
    Public CheckValueChange = False
    Public KeyPressIndex As Integer = -1
#End Region

#Region "Properties"
    Public Property Project() As Integer
        Get
            Return projectID
        End Get
        Set(ByVal value As Integer)
            projectID = value
        End Set
    End Property
#End Region

#Region "Constructor"

    Public Sub New()
        InitializeComponent()
        GetValidatedControls()
        DisableRightClickInTextBox()
    End Sub

#End Region

#Region "Form Events"

    Private Sub frmAddEditProject_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If Not IsSaved Then
            If Project = 0 Then
                If IsContentChange() Then
                    If (MessageBox.Show("Do you want to save the project?", BaseClass.crystalCaption, MessageBoxButtons.OKCancel, MessageBoxIcon.Information) = Windows.Forms.DialogResult.OK) Then
                        ValidationManager.IsButtonClick = True
                        If IsValid() Then
                            e.Cancel = True
                            Exit Sub
                        End If
                        'If IsEmptyControl() Then
                        '    e.Cancel = True
                        '    Exit Sub
                        'End If
                        btnSave.PerformClick()
                        If Not IsSaved Then
                            e.Cancel = True
                        End If
                    End If
                End If
            Else
                If IsProjectcontentChange() Then
                    If (MessageBox.Show("Do you want to save the changes?", BaseClass.crystalCaption, MessageBoxButtons.OKCancel, MessageBoxIcon.Information) = Windows.Forms.DialogResult.OK) Then
                        ValidationManager.IsButtonClick = True
                        If IsValid() Then
                            e.Cancel = True
                            Exit Sub
                        End If
                        'If IsEmptyControl() Then
                        '    e.Cancel = True
                        '    Exit Sub
                        'End If
                        btnSave.PerformClick()
                        If Not IsSaved Then
                            e.Cancel = True
                        End If
                    End If
                End If
            End If
        End If
    End Sub

    Private Sub frmAddEditProject_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'UltraTextEditor1.Text.ToString("###,###,###,###")
        IsLoading = True
        InitControls()
        dteCDate.Enabled = False
        If Project = 0 Then
            chkIgnored.Visible = False
            SetDefaultValues()
            txtReportHistory.Text = "12"
        Else
            cmbClientName.Enabled = False
            GetProjectDetails()
            EnableDisableIgnore()
        End If
        If Project = 0 And cmbClientName IsNot Nothing Then
            If cmbClientName.Value > 0 Then
                ClientID = cmbClientName.Value
                CheckCountry()
            End If
        End If
        If cmbProjectStatus.Value = ProjectStatus.CMPLD Then
            dteCDate.Enabled = True
        End If
        IsLoading = False
        SetDefaultComboDisplay()
    End Sub

#End Region

#Region "Methods"
    Private Sub InitControls()
        InitCombos()
        LoadCountries()
        LoadListingData()
        LoadClients()
        LoadProjectStatus()
    End Sub
    Private Sub SetDefaultComboDisplay()
        cmbClientName.Appearance.ForeColor = Color.Black
        cmbCountry.Appearance.ForeColor = Color.Black
        cmbListing.Appearance.ForeColor = Color.Black
        cmbProjectStatus.Appearance.ForeColor = Color.Black
    End Sub
    Private Sub SetDefaultValues()
        If ClientID = 0 Then
            cmbClientName.Value = CommonCLL.m_strSelectIDValue
            cmbCountry.Value = CommonCLL.m_strSelectIDValue
        Else
            cmbClientName.Value = ClientID
        End If
        rbDDFormNo.Checked = True
        rbDTCListNo.Checked = True
        rbOListNo.Checked = True
        rbSRegisterNo.Checked = True
        'cmbProjectStatus.Value = 0
    End Sub
    Private Sub InitCombos()
        cmbClientName.DisplayMember = "ClientName"
        cmbClientName.ValueMember = "ClientID"

        cmbCountry.DisplayMember = "CountryName"
        cmbCountry.ValueMember = "CountryID"

        cmbProjectStatus.DisplayMember = "ProjectStatus"
        cmbProjectStatus.ValueMember = "ProjectStatusID"
    End Sub
    Private Function IsContentChange() As Boolean
        If cmbClientName.Value > 0 Or dteCDate.Value <> Nothing Or dteFDRD.Value <> Nothing _
                Or dteSDD.Value <> Nothing Or txtFreeFloat.Text.ToString <> String.Empty Or txtRegion.Text <> String.Empty _
                Or txtReportHistory.Text <> "12" Or txtSharesIssue.Text <> String.Empty Or txtSOutstanding.Text <> String.Empty _
                Or rbDDFormNo.Checked = False Or rbDTCListNo.Checked = False Or rbOListNo.Checked = False _
                Or rbSRegisterNo.Checked = False Or IsChangeInGrid() Then
            Return True
        End If
        Return False
    End Function
    Private Function IsChangeInGrid() As Boolean
        Dim ldtProjects As DataTable
        If grdClientDetail.DataSource Is Nothing Then Return False
        ldtProjects = (CType(grdClientDetail.DataSource, DataTable))
        For i As Integer = 0 To ldtProjects.Rows.Count - 1
            If Not CommonCLL.blnRowBlank(ldtProjects.Rows(i)) Then
                Return True
            End If
        Next
        Return False
    End Function
    Private Function IsEmptyControl() As Boolean
        If txtFreeFloat.Text = String.Empty Or txtRegion.Text = String.Empty Or txtReportHistory.Text = String.Empty Or txtSharesIssue.Text = String.Empty _
            Or txtSOutstanding.Text = String.Empty Or dteCDate.Value.ToString = String.Empty Or dteFDRD.Value.ToString = String.Empty Or dteSDD.Value.ToString = "" Then
            Return True
        End If
        Return False
    End Function
    Private Function IsProjectcontentChange() As Boolean
        Dim dataSet As New DataSet
        dataSet = cAddEditProject.GetProjectDetail(projectID)
        If dataSet.Tables(0).Rows(0)("CompletionDate").ToString <> String.Empty And dteCDate.Value IsNot Nothing Then
            If cmbClientName.Value <> dataSet.Tables(0).Rows(0)("ClientID").ToString Or dteCDate.Value.ToString <> dataSet.Tables(0).Rows(0)("CompletionDate").ToString _
            Or dteFDRD.Value.ToString <> dataSet.Tables(0).Rows(0)("FinalDiscRequestDate") Or dteSDD.Value.ToString <> dataSet.Tables(0).Rows(0)("DeliveryDate").ToString _
            Or txtFreeFloat.Text.ToString.Replace(",", "") <> dataSet.Tables(0).Rows(0)("FreeFloatValue").ToString _
            Or txtReportHistory.Text <> dataSet.Tables(0).Rows(0)("ReportHistory").ToString Or txtSharesIssue.Text.ToString.Replace(",", "") <> dataSet.Tables(0).Rows(0)("ShareInIssue").ToString _
            Or txtSOutstanding.Text.ToString.Replace(",", "") <> dataSet.Tables(0).Rows(0)("ShareOutStanding").ToString Or cmbCountry.Value <> dataSet.Tables(0).Rows(0)("CountryID").ToString _
            Or cmbProjectStatus.Value <> dataSet.Tables(0).Rows(0)("ProjectStatusID").ToString _
            Or CreateListingXML(CType(grdClientDetail.DataSource, DataTable)).ToString <> CreateListingXML(dataSet.Tables(1)).ToString Then
                Return True
            End If
        Else
            If cmbClientName.Value <> dataSet.Tables(0).Rows(0)("ClientID").ToString _
            Or dteFDRD.Value.ToString <> dataSet.Tables(0).Rows(0)("FinalDiscRequestDate") Or dteSDD.Value.ToString <> dataSet.Tables(0).Rows(0)("DeliveryDate").ToString _
            Or txtFreeFloat.Text.ToString().Replace(",", "") <> dataSet.Tables(0).Rows(0)("FreeFloatValue").ToString _
            Or txtReportHistory.Text <> dataSet.Tables(0).Rows(0)("ReportHistory").ToString Or txtSharesIssue.Text.ToString.Replace(",", "") <> dataSet.Tables(0).Rows(0)("ShareInIssue").ToString _
            Or txtSOutstanding.Text.ToString.Replace(",", "") <> dataSet.Tables(0).Rows(0)("ShareOutStanding").ToString Or cmbCountry.Value <> dataSet.Tables(0).Rows(0)("CountryID").ToString _
            Or cmbProjectStatus.Value <> dataSet.Tables(0).Rows(0)("ProjectStatusID").ToString _
            Or CreateListingXML(CType(grdClientDetail.DataSource, DataTable)).ToString <> CreateListingXML(dataSet.Tables(1)).ToString Then
                Return True
            End If
        End If
        Return False
    End Function
    Private Function IsValid() As Boolean
        If Not (Me.ValidateChildren()) Then
            ValidationManager.IsButtonClick = False
            'FocusOnEmptyControl()
            Return True
        End If
        ValidationManager.IsButtonClick = False
        Return False
    End Function
    Private Sub BindListingGridClient()
        Dim dtListing As New DataTable
        Dim dataSet As New DataSet
        Dim MsgLog As New System.Text.StringBuilder

        Try
            'dataSet = AddEditClient.GetListingData()
            dtListing = GetGridDataTable()
            AddClientRows(dtListing, 5)
            grdClientDetail.DataSource = dtListing.Copy()

        Catch ex As Exception
            MsgBox(ex.Message)
            MsgLog.Append("There is error in FocusTheExistingInstanceOfForm in Client Management.")
            MsgLog.Append(Environment.NewLine)
            MsgLog.Append("Error Details:- ")
            MsgLog.Append(ex.ToString())
            CreateErrorLog(MsgLog)
            MsgLog = Nothing
        Finally
            dtListing = Nothing
            dataSet = Nothing
        End Try
    End Sub
    Private Shared Function GetGridDataTable() As DataTable
        Dim dtable As New DataTable
        dtable.Columns.Add("Listing", Type.GetType("System.String"))
        dtable.Columns.Add("Ratio", Type.GetType("System.Decimal"))
        dtable.Columns.Add("ISIN", Type.GetType("System.String"))
        dtable.Columns.Add("SEDOL", Type.GetType("System.String"))
        dtable.Columns.Add("CUSIP", Type.GetType("System.String"))
        Return dtable
    End Function
    Private Sub LoadProjectStatus()
        Dim dataSet As New DataSet
        Dim Logmessage As New System.Text.StringBuilder
        Dim dataTable As New DataTable
        Try
            dataSet = cAddEditProject.GetProjectStatus()
            dataTable = dataSet.Tables(0)
            cmbProjectStatus.DataSource = dataTable
            If projectID = 0 Then
                cmbProjectStatus.Value = 1
            End If
            'cmbListing.DataSource = dataTable
        Catch ex As Exception
            Throw ex
            Logmessage.Append("There is error in LoadListingData of form AddEdit.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        Finally
            dataSet = Nothing
            dataTable = Nothing
            Logmessage = Nothing
        End Try
    End Sub
    Private Sub LoadClients()
        Dim dataSet As New DataSet
        Dim Logmessage As New System.Text.StringBuilder
        Dim dataTable As New DataTable
        Try
            dataSet = cAddEditProject.GetClients()
            dataTable = dataSet.Tables(0)
            cmbClientName.DataSource = dataTable
            'cmbListing.DataSource = dataTable
        Catch ex As Exception
            Throw ex
            Logmessage.Append("There is error in LoadListingData of form AddEdit.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        Finally
            dataSet = Nothing
            dataTable = Nothing
            Logmessage = Nothing
        End Try
    End Sub
    Private Sub LoadCountries()
        Dim dataSet As New DataSet
        Dim Logmessage As New System.Text.StringBuilder
        Dim dataTable As New DataTable
        Try
            dataSet = cAddEditProject.GetCountries()
            dataTable = dataSet.Tables(0)
            cmbCountry.DataSource = dataTable
            'cmbListing.DataSource = dataTable
        Catch ex As Exception
            Throw ex
            Logmessage.Append("There is error in LoadListingData of form AddEdit.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        Finally
            dataSet = Nothing
            dataTable = Nothing
            Logmessage = Nothing
        End Try
    End Sub
    Private Sub LoadListingData()
        Dim dataSet As New DataSet
        Dim Logmessage As New System.Text.StringBuilder
        Dim dataTable As New DataTable
        Try
            dataSet = AddEditClient.GetClientData()
            dataTable = dataSet.Tables(0)
            Dim dataRow As DataRow = dataTable.Rows(5)
            'Remove other option and Add --New-- Option in comboListing
            dataTable.Rows.Remove(dataRow)
            dataRow = dataTable.NewRow()
            dataRow.Item("Listing") = "--New--"
            dataTable.Rows.InsertAt(dataRow, 0)
            dataTable = BaseClass.BlankRowAtLastDataTable(dataTable)
            cmbListing.DataSource = dataTable
        Catch ex As Exception
            Throw ex
            Logmessage.Append("There is error in LoadListingData of form AddEdit.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        Finally
            dataSet = Nothing
            dataTable = Nothing
            Logmessage = Nothing
        End Try
    End Sub
    Private Sub GetValidatedControls()

        RangeValidator(txtSharesIssue, "999999999999999", "0", lblSInIssue.Text)
        RangeValidator(txtSOutstanding, "999999999999999", "0", lblSInIssue.Text)
        RangeValidator(txtFreeFloat, "999999999999999", "0", lblFreeFloat.Text)
        RangeValidator(txtReportHistory, "255", "0", lblReportHistory.Text)
        RequiredValidateControl(txtReportHistory, "Report history")

        RequiredValidateControl(cmbClientName, "Client name")
        RequiredValidateControl(cmbCountry, "Country")
        RequiredValidateControl(cmbProjectStatus, "ProjectStatus")
        RequiredDateTimeControl(dteSDD, "Schedule deilvery date")
        RequiredDateTimeControl(dteFDRD, "Final disc. request date")
        'RequiredDateTimeControl(dteSDD, "Completed date")
    End Sub
    Private Sub DisableRightClickInTextBox()
        DisableRightClickInfTextEditor(txtFreeFloat)
        DisableRightClickInfTextEditor(txtRegion)
        DisableRightClickInfTextEditor(txtReportHistory)
        DisableRightClickInfTextEditor(txtSharesIssue)
        DisableRightClickInfTextEditor(txtSOutstanding)
    End Sub
    Private Function IsRowExist() As Boolean
        Dim ldtProjects As DataTable
        If grdClientDetail.Rows.Count > 0 Then
            ldtProjects = (CType(grdClientDetail.DataSource, DataTable))
            For i As Integer = 0 To ldtProjects.Rows.Count - 1
                If Not CommonCLL.blnRowBlank(ldtProjects.Rows(i)) Then
                    Return True
                End If
            Next
        End If
        Return False
    End Function
    Protected Function CreateListingXML(ByVal ldtProjects As DataTable) As StringBuilder
        Dim i As Integer
        Dim Logmessage As New System.Text.StringBuilder

        'Dim ldtProjects As DataTable
        Dim sbXML As New StringBuilder
        Try
            If ldtProjects.Rows.Count > 0 Then
                ' ldtProjects = (CType(grdClientDetail.DataSource, DataTable))
                sbXML.Append("<Root>")
                For i = 0 To ldtProjects.Rows.Count - 1
                    If Not CommonCLL.blnRowBlank(ldtProjects.Rows(i)) Then
                        sbXML.Append("<Row ListingName=""" & ldtProjects.Rows(i)(0).ToString().Replace("'", "&apos;").Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace(ControlChars.Quote, "&quot;") & """ " & _
                                 "Ratio=""" & ldtProjects.Rows(i)(1).ToString().Replace("'", "&apos;").Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace(ControlChars.Quote, "&quot;") & """ " & _
                                 "ISIN=""" & ldtProjects.Rows(i)(2).ToString().Replace("'", "&apos;").Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace(ControlChars.Quote, "&quot;") & """ " & _
                                 "SEDOL=""" & ldtProjects.Rows(i)(3).ToString().Replace("'", "&apos;").Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace(ControlChars.Quote, "&quot;") & """ " & _
                                 "CUSIP=""" & ldtProjects.Rows(i)(4).ToString().Replace("'", "&apos;").Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace(ControlChars.Quote, "&quot;") & """ " & _
                                 "SequenceID=""" & (i + 1).ToString().Replace("'", "&apos;").Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace(ControlChars.Quote, "&quot;") & """ " & _
                             "/>")
                        sbXML.Append(vbNewLine)
                    End If

                Next
                sbXML.Append("</Root>")

            End If

        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Logmessage.Append("There is error in grdClientDetail_AfterCellListCloseUp of form findmanagement.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        End Try
        Return sbXML
    End Function
    Private Sub AddUpdateProject()
        Dim Logmessage As New System.Text.StringBuilder
        Dim obj As New cAddEditProject
        Dim valie As Int64
        Dim dataTable As New DataTable
        Try
            obj.cProjectID = projectID
            obj.cClientID = cmbClientName.Value
            obj.cProjectName = ""
            dataTable = CType(grdClientDetail.DataSource, DataTable)

            obj.cListing = CreateListingXML(dataTable).ToString
            obj.cProductTypeID = 1
            obj.cSDD = If(dteSDD.Value Is Nothing, DateTime.MinValue, dteSDD.Value)
            obj.cFDRD = If(dteFDRD.Value Is Nothing, DateTime.MinValue, dteFDRD.Value) 'dteFDRD.Value
            obj.cProjectStatusID = cmbProjectStatus.Value
            obj.cIsIgnored = chkIgnored.Checked
            obj.cCompletionDate = If(dteCDate.Value Is Nothing, DateTime.MinValue, dteCDate.Value)
            If txtSharesIssue.Text = String.Empty Then
                valie = 0
            Else
                valie = Convert.ToInt64(txtSharesIssue.Text.ToString.Replace(",", ""))
            End If
            obj.cShareinIssue = valie
            If txtSOutstanding.Text = String.Empty Then
                valie = 0
            Else
                valie = Convert.ToInt64(txtSOutstanding.Text.ToString.Replace(",", ""))
            End If
            'valie = Convert.ToInt64(txtSOutstanding.Text.ToString.Replace(",", ""))
            obj.cShareOutstanding = valie
            If txtFreeFloat.Text = String.Empty Then
                valie = 0
            Else
                valie = Convert.ToInt64(txtFreeFloat.Text.ToString.Replace(",", ""))
            End If
            'valie = Convert.ToInt64(txtFreeFloat.Text.ToString.Replace(",", ""))
            obj.cFreeFloatValue = valie  'If(txtFreeFloat.Text = String.Empty, 0, valie)
            obj.cIsShareOutstandingAutomatic = True
            obj.cIsFreeFloat = True
            obj.IsFreeFloatAutomatic = True
            obj.cCountryID = cmbCountry.Value
            obj.cReportHistory = Convert.ToInt32(txtReportHistory.Text.ToString.Replace(",", ""))
            obj.HasDDForm = If(rbDDFormY.Checked, rbDDFormY.Text, If(rbDDFormNo.Checked, rbDDFormNo.Text, "NA"))
            obj.HasDTCList = If(rbDTCListY.Checked, rbDTCListY.Text, If(rbDTCListNo.Checked, rbDTCListNo.Text, "NA"))
            obj.HasOfferingList = If(rbOListY.Checked, rbOListY.Text, If(rbOListNo.Checked, rbOListNo.Text, "NA"))
            obj.HasShareRegister = If(rbSRegisterY.Checked, rbSRegisterY.Text, If(rbSRegisterNo.Checked, rbSRegisterNo.Text, "NA"))
            obj.cCreatedBy = 1
            obj.cModifiedBy = 1
            projectID = obj.InsertProject()
            cAddEditProject.AutoGeneratedColumns(projectID, CommonCLL.UserID)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Logmessage.Append("There is error in AddUpdateClient of form findmanagement.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        Finally
            obj = Nothing
        End Try
    End Sub
    Private Sub CheckCountry()
        Dim Logmessage As New System.Text.StringBuilder
        Dim dataSet As New DataSet
        Try
            dataSet = cAddEditProject.CheckCountry(ClientID)
            If dataSet.Tables.Count > 0 Then
                If dataSet.Tables(0).Rows.Count > 0 Then
                    If dataSet.Tables(0).Rows(0)(0).ToString <> String.Empty Then
                        cmbCountry.Value = dataSet.Tables(0).Rows(0)(0).ToString
                        txtSharesIssue.Text = dataSet.Tables(0).Rows(0)("ShareInIssue").ToString
                        txtSOutstanding.Text = dataSet.Tables(0).Rows(0)("ShareOutStanding").ToString
                        txtFreeFloat.Text = dataSet.Tables(0).Rows(0)("FreeFloatValue").ToString
                    End If
                End If
                If dataSet.Tables(1) IsNot Nothing Then
                    If dataSet.Tables(1).Rows.Count > 0 Then
                        grdClientDetail.DataSource = dataSet.Tables(1)
                    End If
                End If
            End If

        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Logmessage.Append("There is error in SetClientDetail of form findmanagement.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        Finally
            dataSet = Nothing
        End Try
    End Sub
    Private Sub GetProjectDetails()
        Dim Logmessage As New System.Text.StringBuilder
        Dim dataSet As New DataSet
        Try
            dataSet = cAddEditProject.GetProjectDetail(Project)
            SetProjectData(dataSet.Tables(AddEditClient.ClientDetail.Client))
            SetClientListing(dataSet.Tables(AddEditClient.ClientDetail.Listing).Copy())
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Logmessage.Append("There is error in SetClientDetail of form findmanagement.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        Finally
            dataSet = Nothing
        End Try
    End Sub

    Private Sub EnableDisableIgnore()
        Dim Logmessage As New System.Text.StringBuilder
        Try
            IgnoreEnable = cAddEditProject.CheckEnableIgnore(Project)
            If IgnoreEnable Then
                chkIgnored.Enabled = True
            Else
                chkIgnored.Enabled = False
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Logmessage.Append("There is error in SetClientDetail of form findmanagement.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        Finally
            'DataSet = Nothing
        End Try
    End Sub


#End Region

#Region "Events"

    Private Sub btnUpList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpList.Click
        If Not IsRowExist() Then
            Exit Sub
        End If
        If grdClientDetail.Rows.Count = 1 Then
            Exit Sub
        End If
        Dim index As Integer = grdClientDetail.ActiveRow.Index
        Dim dataTable As DataTable = CType(grdClientDetail.DataSource, DataTable)
        Dim dRow As DataRow = dataTable.NewRow()
        'dRow = dataTable.Rows(index - 1)
        If index = 0 Then Exit Sub
        If CommonCLL.blnRowBlank(dataTable.Rows(index)) Then
            Exit Sub
        End If
        For i As Integer = 0 To dataTable.Columns.Count - 1
            dRow(i) = dataTable.Rows(index - 1)(i).ToString
        Next
        dataTable.Rows.RemoveAt(index - 1)
        dataTable.Rows.InsertAt(dRow, index)
        EnableDisableUpDownButtons()
    End Sub

    Private Sub btnDownList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownList.Click
        If Not IsRowExist() Then
            Exit Sub
        End If
        If grdClientDetail.Rows.Count = 1 Then
            Exit Sub
        End If
        Dim index As Integer = grdClientDetail.ActiveRow.Index
        Dim dataTable As DataTable = CType(grdClientDetail.DataSource, DataTable)
        Dim dRow As DataRow = dataTable.NewRow()
        'dRow = dataTable.Rows(index - 1)
        If CommonCLL.blnRowBlank(dataTable.Rows(index + 1)) Then
            Exit Sub
        End If
        For i As Integer = 0 To dataTable.Columns.Count - 1
            dRow(i) = dataTable.Rows(index + 1)(i).ToString
        Next
        dataTable.Rows.RemoveAt(index + 1)
        dataTable.Rows.InsertAt(dRow, index)
        EnableDisableUpDownButtons()
    End Sub

    Private Sub btnAddList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddList.Click
        Dim data As DataTable = CType(grdClientDetail.DataSource, DataTable)
        AddClientRows(data, 1)
        grdClientDetail.DataSource = data
    End Sub

    Private Sub AddClientRows(ByRef dtable As DataTable, ByVal count As Integer)
        If dtable IsNot Nothing Then
            Dim row As DataRow
            For i As Integer = 0 To count - 1
                row = dtable.NewRow()
                row.Item(0) = DBNull.Value
                row.Item(1) = DBNull.Value
                row.Item(2) = DBNull.Value
                row.Item(3) = DBNull.Value
                row.Item(4) = DBNull.Value
                dtable.Rows.Add(row)
            Next
        End If

    End Sub

    Private Sub grdClientDetail_AfterCellListCloseUp(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CellEventArgs) Handles grdClientDetail.AfterCellListCloseUp
        Dim gridData As New DataTable
        Dim rowsField() As DataRow
        Dim strSelectedField As String
        Dim Id As String = String.Empty
        Dim Listing As String = String.Empty
        Dim dsReturn As New DataSet
        Dim Logmessage As New System.Text.StringBuilder

        Try
            strSelectedField = grdClientDetail.ActiveRow.Cells("Listing").Text.ToString()
            If strSelectedField = String.Empty Then
                Exit Sub
            End If
            If e.Cell.Text.ToString.ToLower = "--new--" Then
                Dim objAddValue As New CrystalCommon.View.AddValue(enmEntityType.Source.ToString(), LKPMaster.LSTNG, "Listing")
                objAddValue.ShowDialog()
                Id = objAddValue.ID
                If Id <> String.Empty Then
                    dsReturn = AddEditClient.GetTopListing(Convert.ToInt16(Id.ToString))
                    If dsReturn IsNot Nothing Then
                        Listing = dsReturn.Tables(0).Rows(0)("Listing").ToString()
                        'Id = dsReturn.Tables(0).Rows(0)("ListingID").ToString()
                        Dim table As DataTable = cmbListing.DataSource
                        If table.Columns.Contains("Listing") Then
                            Dim FilterQuery As String
                            Dim Excel() As DataRow
                            FilterQuery = "Listing ='" + Trim(Listing).Replace("'", "''") + "'"
                            Excel = table.Select(FilterQuery)
                            If Excel.Length = 0 Then
                                table = BaseClass.InsertRowAtLastDataTable(table, Listing, "Listing")

                                cmbListing.Text = Listing
                            Else
                                e.Cell.Value = Excel(0).Item(0).ToString
                            End If
                        End If
                    End If
                Else
                    e.Cell.CancelUpdate()
                End If
            Else
                gridData = grdClientDetail.DataSource
                Dim lstrFieldValue As String = e.Cell.Text ' grdClientDetail.ActiveRow.Cells("Listing").Value.ToString
                rowsField = gridData.Select("[Listing]='" & lstrFieldValue & "'")
                If rowsField.Length > 0 Then
                    If gridData.Rows.IndexOf(rowsField(0)) = grdClientDetail.ActiveRow.Index Then

                    Else
                        MessageBox.Show("Column '" & grdClientDetail.ActiveRow.Cells("Listing").Text & "' has been already selected.", BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                        e.Cell.CancelUpdate() '.Type.Cancel = True '.Cell.CancelUpdate() '.Cancel = True
                        Exit Sub
                    End If
                End If

            End If
        Catch ex As Exception
            Logmessage.Append("There is error in grdClientDetail_AfterCellListCloseUp of form findmanagement.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        End Try
    End Sub

    Private Sub grdClientDetail_AfterSelectChange(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.AfterSelectChangeEventArgs) Handles grdClientDetail.AfterSelectChange
        If grdClientDetail.Selected.Rows.Count > 1 Then
            MultiRowSelection(False)
        Else
            MultiRowSelection(True)
            EnableDisableUpDownButtons()
        End If
    End Sub

    Private Sub MultiRowSelection(ByVal isTrue As Boolean)
        btnUpList.Enabled = isTrue
        btnDownList.Enabled = isTrue
    End Sub

    Private Sub EnableDisableUpDownButtons()
        DefaultDisableButton()
        If grdClientDetail.ActiveRow.Index = 0 Then
            btnUpList.Enabled = False
        Else
            btnUpList.Enabled = True
        End If
        If grdClientDetail.ActiveRow.Index = grdClientDetail.Rows.Count - 1 Then
            btnDownList.Enabled = False
        Else
            btnDownList.Enabled = True
        End If
    End Sub

    Private Sub DefaultDisableButton()
        If grdClientDetail.Rows.Count > 1 Then
            btnUpList.Enabled = True
            btnDownList.Enabled = True
        Else
            btnUpList.Enabled = False
            btnDownList.Enabled = False
        End If
    End Sub

    Private Sub SetClientListing(ByVal listing As DataTable)
        grdClientDetail.DataSource = listing
    End Sub

    Private Sub SetClientDetail()
        Dim Logmessage As New System.Text.StringBuilder
        Dim dataSet As New DataSet
        Try
            If cmbClientName.Value > 0 Then
                dataSet = AddEditClient.GetClientDetail(Convert.ToInt16(cmbClientName.Value))
                SetClientData(dataSet.Tables(AddEditClient.ClientDetail.Client))
                SetClientListing(dataSet.Tables(AddEditClient.ClientDetail.Listing).Copy())
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Logmessage.Append("There is error in SetClientDetail of form findmanagement.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        Finally
            dataSet = Nothing
        End Try
    End Sub

    Private Sub SetClientData(ByVal data As DataTable)
        If data.Rows.Count > 0 Then
            cmbCountry.Value = data.Rows(0)("CountryID").ToString
            txtRegion.Text = data.Rows(0)("Region").ToString
            'cmbClientName.Value = data.Rows(0)("ClientID").ToString
        End If
    End Sub

    Private Sub SetProjectData(ByVal data As DataTable)
        If data.Rows.Count > 0 Then
            cmbClientName.Value = data.Rows(0)("ClientID").ToString
            cmbCountry.Value = data.Rows(0)("CountryID").ToString
            txtRegion.Text = data.Rows(0)("Region").ToString
            cmbProjectStatus.Value = data.Rows(0)("ProjectStatusID").ToString
            txtSharesIssue.Value = data.Rows(0)("ShareInIssue").ToString
            txtSOutstanding.Value = data.Rows(0)("ShareOutStanding").ToString
            txtFreeFloat.Value = data.Rows(0)("FreeFloatValue").ToString
            dteCDate.Value = data.Rows(0)("CompletionDate").ToString
            dteFDRD.Value = data.Rows(0)("FinalDiscRequestDate").ToString
            dteSDD.Value = data.Rows(0)("DeliveryDate").ToString
            txtReportHistory.Text = data.Rows(0)("ReportHistory").ToString
            If data.Rows(0)("HasDDForm").ToString = "Yes" Then
                rbDDFormY.Checked = True
            ElseIf data.Rows(0)("HasDDForm").ToString = "No" Then
                rbDDFormNo.Checked = True
            ElseIf data.Rows(0)("HasDDForm").ToString = "NA" Then
                rbDDFormNA.Checked = True
            End If
            If data.Rows(0)("HasDTCList").ToString = "Yes" Then
                rbDTCListY.Checked = True
            ElseIf data.Rows(0)("HasDTCList").ToString = "No" Then
                rbDTCListNo.Checked = True
            ElseIf data.Rows(0)("HasDTCList").ToString = "NA" Then
                rbDTCListNA.Checked = True
            End If
            If data.Rows(0)("HasOfferingList").ToString = "Yes" Then
                rbOListY.Checked = True
            ElseIf data.Rows(0)("HasOfferingList").ToString = "No" Then
                rbOListNo.Checked = True
            ElseIf data.Rows(0)("HasOfferingList").ToString = "NA" Then
                rbOListNA.Checked = True
            End If
            If data.Rows(0)("HasShareRegister").ToString = "Yes" Then
                rbSRegisterY.Checked = True
            ElseIf data.Rows(0)("HasShareRegister").ToString = "No" Then
                rbSRegisterNo.Checked = True
            ElseIf data.Rows(0)("HasShareRegister").ToString = "NA" Then
                rbSRegisterNA.Checked = True
            End If
        End If
    End Sub

    Private Sub cmbClientName_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbClientName.SelectionChanged
        If Project <> 0 Then
            SetClientDetail()
        Else
            If cmbClientName.Value = 0 Then
                BindListingGridClient()
            Else
                SetClientDetail()
            End If
        End If
        If Project = 0 And cmbClientName IsNot Nothing Then
            If cmbClientName.Value > 0 Then
                ClientID = cmbClientName.Value
                CheckCountry()
            End If
        End If
    End Sub

    Private Sub grdClientDetail_BeforeRowUpdate(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CancelableRowEventArgs) Handles grdClientDetail.BeforeRowUpdate
        Dim datatable As New DataTable
        Dim index As Integer = grdClientDetail.ActiveRow.Index
        Dim gridRow As UltraGridRow = e.Row
        Dim drv As DataRowView = TryCast(gridRow.ListObject, DataRowView)
        Dim row As DataRow = If(drv IsNot Nothing, drv.Row, Nothing)
        If Not CommonCLL.blnRowBlank(row) Then
            If row.Item("Listing").ToString = String.Empty Then
                MessageBox.Show(MessageManager.GetMessage("SELECTLISTING"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                e.Cancel = True
            ElseIf row.Item("Ratio").ToString = String.Empty Then
                MessageBox.Show(MessageManager.GetMessage("ENTER_RATIO"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                e.Cancel = True
            ElseIf row.Item("ISIN").ToString = String.Empty And row.Item("SEDOL").ToString = String.Empty Then
                MessageBox.Show("Please enter the ISIN or SEDOL.", BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                e.Cancel = True
            End If
        Else
            e.Row.Delete()
            If e.Row.IsDeleted Then
                datatable = CType(grdClientDetail.DataSource, DataTable)
                datatable.Rows(index).Delete()
                datatable.AcceptChanges()
                'grdClientDetail.UpdateData()
            End If
        End If
    End Sub

    Private Sub grdClientDetail_ClickCell(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.ClickCellEventArgs) Handles grdClientDetail.ClickCell
        EnableDisableUpDownButtons()
    End Sub

    Private Sub grdClientDetail_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles grdClientDetail.InitializeLayout
        Dim Logmessage As New System.Text.StringBuilder
        Try
            e.Layout.Bands(0).Columns("Listing").EditorComponent = Me.cmbListing
            e.Layout.Bands(0).Columns("Listing").CellAppearance.BorderAlpha = Alpha.UseAlphaLevel
            e.Layout.Bands(0).Columns("Listing").ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.Always
            Me.grdClientDetail.DisplayLayout.Bands(0).Columns("Listing").Style = UltraWinGrid.ColumnStyle.DropDownList

            e.Layout.Bands(0).Columns("Ratio").Format = "####.####"
            e.Layout.Bands(0).Columns("Ratio").MinValue = 0.0001 ' .Format = "nnnn.nnnn"
            e.Layout.Bands(0).Columns("Ratio").MaxValue = 1000.0
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Logmessage.Append("There is error in grdClientDetail_AfterCellListCloseUp of form findmanagement.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        End Try
    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub

    Private Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Dim Logmessage As New System.Text.StringBuilder
        Dim Id As Integer = projectID

        Try
            If txtReportHistory.Text <> String.Empty Then
                If Convert.ToInt16(txtReportHistory.Text) > 255 Then
                    MessageBox.Show("Report history should be less than 255.", BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                    Return
                End If
            End If
            ValidationManager.IsButtonClick = True
            If IsValid() Then
                Return
            End If
            If grdClientDetail Is Nothing Then
                MessageBox.Show(MessageManager.GetMessage("NULL_LISTING"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                Exit Sub
            ElseIf Not IsRowExist() Then
                MessageBox.Show(MessageManager.GetMessage("NULL_LISTING"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                Exit Sub
            End If

            If Id = 0 Then
                If cAddEditProject.IsProjectNameExist(cmbClientName.Value, dteSDD.Value) = True Then
                    MessageBox.Show(MessageManager.GetMessage("PROJECT_SDD_EXIST"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                    Exit Sub
                End If
            End If
            AddUpdateProject()
            If Id = 0 And projectID = 0 Then Exit Sub
            If Id = 0 Then
                MessageBox.Show(MessageManager.GetMessage("PROJECTCREATED"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
            Else
                MessageBox.Show(MessageManager.GetMessage("PROJECTUPDATED"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
            End If
            RaiseEvent AddParticularProjectInGrid(projectID)
            IsSaved = True
            ' Me.Close()
        Catch ex As Exception
            Throw ex
            Logmessage.Append("There is error in LoadListingData of form AddEdit.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        Finally
            Logmessage = Nothing
        End Try
    End Sub

    Private Sub cmbCountry_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbCountry.SelectionChanged
        Dim dataSet As New DataSet
        Dim Logmessage As New System.Text.StringBuilder
        Dim dataTable As New DataTable
        Try
            If cmbCountry.Value Is Nothing Then Exit Sub
            If IsLoading = False Then
                dataSet = cAddEditProject.GetRegionCountry(cmbCountry.Value)
                dataTable = dataSet.Tables(0)
                txtRegion.Text = dataTable.Rows(0)(0)
            End If
            'cmbListing.DataSource = dataTable
        Catch ex As Exception
            Throw ex
            Logmessage.Append("There is error in LoadListingData of form AddEdit.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        Finally
            dataSet = Nothing
            dataTable = Nothing
            Logmessage = Nothing
        End Try
    End Sub

    Private Sub txtFreeFloat_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtFreeFloat.KeyPress
        Try
            CheckValueChange = True
            Dim st As String
            If (e.KeyChar.ToString() = "." Or e.KeyChar.ToString() = "-") Then
                e.Handled = True
                Return
            End If
            'Dim 
            If Clipboard.ContainsText() Then
                st = Clipboard.GetText()
                If (Validations.CheckNumericString(st) = False) Then
                    e.Handled = True
                    Clipboard.Clear()
                Else
                    e.Handled = False
                End If
            Else
                '  e.Handled = False
                If (Validations.CheckNumeric(e.KeyChar) = False) Then
                    e.Handled = True
                Else
                    e.Handled = False
                End If
            End If
            CheckValueChange = False
            'txtFreeFloat.Text = CommonCLL.AddSeprator(txtFreeFloat.Text)
            'txtFreeFloat.SelectionStart = txtSharesIssue.Text.Length
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            ' nonNumberEntered = False
        End Try
    End Sub

    Private Sub txtSharesIssue_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtSharesIssue.KeyPress
        Try
            Dim st As String
            'KeyPressIndex = txtSharesIssue.
            CheckValueChange = True
            If (e.KeyChar.ToString() = "." Or e.KeyChar.ToString() = "-") Then
                e.Handled = True
                Return
            End If
            If Clipboard.ContainsText() Then
                st = Clipboard.GetText()
                If (Validations.CheckNumericString(st) = False) Then
                    e.Handled = True
                    Clipboard.Clear()
                Else
                    e.Handled = False
                End If
            Else
                '  e.Handled = False
                If (Validations.CheckNumeric(e.KeyChar) = False) Then
                    e.Handled = True
                Else
                    e.Handled = False
                End If
            End If
            CheckValueChange = False
            'txtSharesIssue.Text = CommonCLL.AddSeprator(txtSharesIssue.Text)
            'txtSharesIssue.SelectionStart = txtSharesIssue.Text.Length
            'txtSharesIssue...a.Update()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            ' nonNumberEntered = False
        End Try
    End Sub

    Private Sub txtSOutstanding_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtSOutstanding.KeyPress
        Try
            Dim st As String
            CheckValueChange = True
            If (e.KeyChar.ToString() = "." Or e.KeyChar.ToString() = "-") Then
                e.Handled = True
                Return
            End If
            If Clipboard.ContainsText() Then
                st = Clipboard.GetText()
                If (Validations.CheckNumericString(st) = False) Then
                    e.Handled = True
                    Clipboard.Clear()
                Else
                    e.Handled = False
                End If
            Else
                '  e.Handled = False
                If (Validations.CheckNumeric(e.KeyChar) = False) Then
                    e.Handled = True
                Else
                    e.Handled = False
                End If
            End If
            CheckValueChange = False
            'txtSOutstanding.Text = CommonCLL.AddSeprator(txtSOutstanding.Text)
            'txtSOutstanding.SelectionStart = txtSOutstanding.Text.Length
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            ' nonNumberEntered = False
        End Try
    End Sub

    Private Sub txtReportHistory_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtReportHistory.KeyPress
        Try
            Dim st As String
            If (e.KeyChar.ToString() = "." Or e.KeyChar.ToString() = "-") Then
                e.Handled = True
                Return
            End If
            If Clipboard.ContainsText() Then
                st = Clipboard.GetText()
                If (Validations.CheckNumericString(st) = False) Then
                    e.Handled = True
                    Clipboard.Clear()
                Else
                    e.Handled = False
                End If
            Else
                '  e.Handled = False
                If (Validations.CheckNumeric(e.KeyChar) = False) Then
                    e.Handled = True
                Else
                    e.Handled = False
                End If
            End If
            CheckValueChange = False
            'txtReportHistory.Text = CommonCLL.AddSeprator(txtReportHistory.Text)
            'txtReportHistory.SelectionStart = txtSharesIssue.Text.Length
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            ' nonNumberEntered = False
        End Try
    End Sub

#End Region

    Private Sub cmbProjectStatus_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbProjectStatus.SelectionChanged
        If IsLoading = False Then
            Dim bool As Boolean = False
            If Project = 0 Then
                If (cmbProjectStatus.Value <> 1 Or cmbProjectStatus.Value <> 2) Then
                    MessageBox.Show(MessageManager.GetMessage("MANUAL_SELECTION"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                    IsLoading = True
                    cmbProjectStatus.Value = 1
                    IsLoading = False
                End If
            Else
                bool = cAddEditProject.CheckEnableIgnore(Project)
                If bool Then
                    If cmbProjectStatus.Value <> 5 Then
                        MessageBox.Show(MessageManager.GetMessage("COMPLTD_PRJECT"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                        IsLoading = True
                        cmbProjectStatus.Value = 5
                        IsLoading = False
                    End If
                Else
                    If (cmbProjectStatus.Value = 3 Or cmbProjectStatus.Value = 4 Or cmbProjectStatus.Value = 5) Then
                        MessageBox.Show(MessageManager.GetMessage("MANUAL_SELECTION"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                        IsLoading = True
                        cmbProjectStatus.Value = 1
                        IsLoading = False
                    End If
                End If
                'If 
            End If
        End If
    End Sub

    Private Sub rbDDFormNo_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbDDFormNo.CheckedChanged
        If Project = 0 Then
            If cmbClientName.Value > 0 Then
                If cAddEditProject.CheckClientProject(cmbClientName.Value) = False Then
                    If rbDDFormNo.Checked = False Then
                        MessageBox.Show(MessageManager.GetMessage("DEFAULT_SELECTION_RB"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                        rbDDFormNo.Checked = True
                    End If
                End If
            End If
        End If
    End Sub

    Private Sub rbDTCListNo_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbDTCListNo.CheckedChanged
        If Project = 0 Then
            If cmbClientName.Value > 0 Then
                If cAddEditProject.CheckClientProject(cmbClientName.Value) = False Then
                    If rbDTCListNo.Checked = False Then
                        MessageBox.Show(MessageManager.GetMessage("DEFAULT_SELECTION_RB"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                        rbDTCListNo.Checked = True
                    End If
                End If
            End If
        End If
    End Sub

    Private Sub rbOListNo_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbOListNo.CheckedChanged
        If Project = 0 Then
            If cmbClientName.Value > 0 Then
                If cAddEditProject.CheckClientProject(cmbClientName.Value) = False Then
                    If rbOListNo.Checked = False Then
                        MessageBox.Show(MessageManager.GetMessage("DEFAULT_SELECTION_RB"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                        rbOListNo.Checked = True
                    End If
                End If
            End If
        End If
    End Sub

    Private Sub rbSRegisterNo_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbSRegisterNo.CheckedChanged
        If Project = 0 Then
            If cmbClientName.Value > 0 Then
                If cAddEditProject.CheckClientProject(cmbClientName.Value) = False Then
                    If rbSRegisterNo.Checked = False Then
                        MessageBox.Show(MessageManager.GetMessage("DEFAULT_SELECTION_RB"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                        rbSRegisterNo.Checked = True
                    End If
                End If
            End If
        End If
    End Sub

    'Private Sub UltraTextEditor1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSharesIssue.ValueChanged
    '    If CheckValueChange Then
    '        Dim stri As String = String.Empty
    '        stri = CommonCLL.AddSeprator(txtSharesIssue.Text)
    '        CheckValueChange = False
    '        txtSharesIssue.Text = stri
    '        'txtSharesIssue.CanSelect = False '.SendToBack()
    '        'txtSharesIssue.Focus() 'ed = True
    '        'Me.Activate()
    '    End If
    'End Sub

    'Private Sub txtFreeFloat_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtFreeFloat.ValueChanged
    '    If CheckValueChange Then
    '        txtFreeFloat.Text = CommonCLL.AddSeprator(txtFreeFloat.Text)
    '        Me.Activate()
    '        CheckValueChange = False
    '    End If
    'End Sub

    'Private Sub txtSOutstanding_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSOutstanding.ValueChanged
    '    If CheckValueChange Then
    '        txtSOutstanding.Text = CommonCLL.AddSeprator(txtSOutstanding.Text)
    '        Me.ActiveControl = txtSOutstanding
    '        CheckValueChange = False
    '    End If
    'End Sub

    Private Sub txtSharesIssue_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSharesIssue.TextChanged
        If txtSharesIssue.Text = String.Empty Then Exit Sub
        If CheckValueChange = False Then
            Dim value As Int64
            Dim stringValue As String = txtSharesIssue.Text
            stringValue = stringValue.Replace(",", "")
            Dim isbool As Boolean = False
            isbool = Int64.TryParse(stringValue, value)
            If isbool Then
                stringValue = value.ToString("#,##0")
            End If
            CheckValueChange = True
            txtSharesIssue.Text = stringValue
            CheckValueChange = False
            'txtSharesIssue.Update()
            txtSharesIssue.SelectionStart = txtSharesIssue.Text.Length
        End If

        ' txtSharesIssue.Text = output
    End Sub

    Private Sub txtSOutstanding_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSOutstanding.TextChanged
        If txtSOutstanding.Text = String.Empty Then Exit Sub
        If CheckValueChange = False Then
            Dim value As Int64
            Dim stringValue As String = txtSOutstanding.Text
            stringValue = stringValue.Replace(",", "")
            Dim isbool As Boolean = False
            isbool = Int64.TryParse(stringValue, value)
            If isbool Then
                stringValue = value.ToString("#,##0")
            End If
            CheckValueChange = True
            txtSOutstanding.Text = stringValue
            CheckValueChange = False
            txtSOutstanding.SelectionStart = txtSOutstanding.Text.Length
        End If
    End Sub

    Private Sub txtFreeFloat_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtFreeFloat.TextChanged
        If txtFreeFloat.Text = String.Empty Then Exit Sub
        If CheckValueChange = False Then
            Dim value As Int64
            Dim stringValue As String = txtFreeFloat.Text
            stringValue = stringValue.Replace(",", "")
            Dim isbool As Boolean = False
            isbool = Int64.TryParse(stringValue, value)
            If isbool Then
                stringValue = value.ToString("#,##0")
            End If
            CheckValueChange = True
            txtFreeFloat.Text = stringValue
            CheckValueChange = False
            txtFreeFloat.SelectionStart = txtFreeFloat.Text.Length
        End If
    End Sub

    Private Sub grdClientDetail_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles grdClientDetail.KeyPress
        If grdClientDetail IsNot Nothing Then
            If grdClientDetail.ActiveRow IsNot Nothing Then
                If grdClientDetail.ActiveCell IsNot Nothing Then
                    If grdClientDetail.ActiveCell.Column.Key = "Ratio" Then
                        isNumericStringForCell(e)
                    End If
                End If
            End If
        End If
    End Sub

    Private Sub isNumericStringForCell(ByVal e As System.Windows.Forms.KeyPressEventArgs)
        Try
            Dim st As String
            If Clipboard.ContainsText() Then
                st = Clipboard.GetText()
                If (BaseClass.CheckNumericString(st) = False) Then
                    e.Handled = True
                    Clipboard.Clear()
                Else
                    e.Handled = False
                End If
            Else
                If (BaseClass.CheckNumeric(e.KeyChar) = False) Then
                    e.Handled = True
                Else
                    e.Handled = False
                End If
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            'nonNumberEntered = False
        End Try
    End Sub
End Class